<template>
	<view style="background-color: #f1f1f1;height: 100vh;">
		<view class="two">
			<view class="two-first"></view>
			<view class="two-one">
				<view class="two-oneLeft">单 号 :</view>
				<view class="two-oneRight">{{slqrData.YDRNUM}}</view>
			</view>
			<view class="two-one">
				<view class="two-oneLeft">受理人 :</view>
				<view class="two-oneRight">{{userInfo.NAME}}</view>
			</view>
			<view class="two-one">
				<view class="two-oneLeft">受理时间 :</view>
				<!-- <view class="two-oneRight">{{new Date()}}</view> -->
				<view style="margin-top: 5px;margin-right: 15px;">
					<uni-dateformat :date="timestamp" :threshold="[0,0]" format="yyyy-MM-dd hh:mm:ss"></uni-dateformat>
				</view>
			</view>
			<!-- <view class="two-one">
				<view class="two-oneLeft">预计时间 :</view>
				<view style="margin-top: 5px;margin-right: 0px;">
					<uni-dateformat :date="value1" :threshold="[0,0]" format="yyyy-MM-dd hh:mm:ss"></uni-dateformat>
					
				</view>
				<view style="margin-top: -8px;margin-right: 0px;">
					<u-button @click="click">编辑</u-button>
				</view>
			</view>
			<u-datetime-picker
						:show="show1"
						v-model="value1"
						mode="datetime"
						closeOnClickOverlay
						@confirm="confirm"
						@cancel="cancel"
						@change="change"
						@close="close"
					></u-datetime-picker> -->
		</view>
		<view class="four-item">
			<u-button class="rgzxBox-btn2" type="primary" @click="slqrBtn">受理确认</u-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// slqrData2: {},
				slqrData:{},
				userInfo: {},
				timestamp:'',
				show1: false,
				value1: Number(new Date())+2*60*60*1000,
				current: 1,
				iconUrl: ''
			}
		},
		onLoad(query) {
			console.log(query,'我来受理界面');
			// 从 query 中获取传递过来的数据，并将其转换为对象
			this.slqrData = JSON.parse(query.wData);
			console.log(this.slqrData,'受理确认');
			// this.slqrData2 = this.slqrData.GRP1
			// console.log(this.slqrData2,'最终数据');
			this.userInfo = uni.getStorageSync('userInfo')
			this.timestamp = new Date()
		},
		methods: {
			close() {
				this[`show${this.current}`] = false
			},
			cancel() {
				this[`show${this.current}`] = false
			},
			confirm(e) {
				this[`show${this.current}`] = false
				// this.result(e.value, e.mode)
			},
			change(e) {
				// console.log('change', e)
			},
			click(){
				if(this.value1==''){
					this.value1=Number(new Date())
				}
				this.show1 = true
			},
			async slqrBtn(a,b){
				// if(this.value1==''){
				// 	alert("预计时间未填写");
				// 	return
				// }
				let GRP1 = {
					GRP1: [{
						YFLG:1,
						YDRNUM: this.slqrData.YDRNUM,//单号
						SERPSON: this.userInfo.NAME,//维修人
						SERPHONE: this.userInfo.PHONE,//维修人电话
						SERTIME: this.parseTime(this.value1),//预计时间
					}] 
				}
				let res = await this.$api.x3.x3request("WSGENXDR2",GRP1)
				
					// 请求成功的处理逻辑
					if(res.status=="error"){
						alert(res.message);
						return false;
					}else{
						let resR = JSON.parse(res.message)
						// console.log(resR,'受理确认返回收据');
						if(resR.GRP1.WOK==0){
							// 显示创建成功的消息提示
							 uni.showToast({
							   title: '受理确认成功',
							   icon: 'success',
							   duration: 2000
							});
							this.form=''
							let that = this
							setTimeout(function() {
								uni.redirectTo({url:"/pages/mydzPages/mydzPages"})
							}, 2000);
						}else{
							uni.showToast({
							   title: '受理确认失败',
							   icon: 'error',
							   duration: 2000
							});
						}
					}
			}
		}
	}
</script>

<style>
.two{
	width: 90%;
	margin: 0 auto;
	position: relative;
	top: 40rpx;
	/* height: 365rpx; */
	background-color: white;
	border: 1px solid #f1f1f1;
}
.two-first{
	height: 40rpx;
	border-bottom: 1px solid #f1f1f1;
}
.two-one{
	/* height: 60rpx; */
	display: flex;
	justify-content: space-between;
}
.two-oneLeft{
	width: 190rpx;
	line-height: 68rpx;
	color: gray;
	text-align: right;
}
.two-oneRight{
	width: 350rpx;
	line-height: 68rpx;
	color: gray;
	text-align: left;
}
.four-item{
	width: 90%;
	margin-top: 70rpx;
	margin-left: 40rpx;
}
</style>
